Código fuente de 'Reordena arrays aleatoriamente 2.asp'

<html>

<head>
<title>Reordena arrays aleatoriamente 2 - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
</head>

<p align="center"><b><font size="3">Reordena arrays aleatoriamente 2</font></b>
<body style="font-family: Arial; font-size: 11pt"></p>

<%
'****************************************
' This function randomly reorders the
' array aArray using a quick and dirty
' approach...  It's fast!
'****************************************
Function ReOrderArrayQuickNDirty(ByVal aArray)

  Dim iUpper, iLower, iLoop, iSwapPos, varTmp
  iUpper = UBound(aArray)
  iLower = LBound(aArray)

  Randomize Timer

  'Loop through the array, randomly swapping values
  For iLoop = iLower to iUpper
    'Get an array index to swap
    iSwapPos = Int(Rnd * (iUpper + 1))

    'Swap the current element with the element at iSwapPos
    varTmp = aArray(iLoop)
    aArray(iLoop) = aArray(iSwapPos)
    aArray(iSwapPos) = varTmp
  Next

  ReOrderArrayQuickNDirty = aArray   'Return the jumbled array
End Function

Dim aSites
ReDim aSites(3)

aSites(0) = "www.astalaweb.com"
aSites(1) = "www.infomanuales.com"
aSites(2) = "www.libroteca.net"
aSites(3) = "fondos.astalaweb.com"

response.write "<br><b>Valores del vector: </b><br><br>"

'Display the array in-order
Dim iLoop
For iLoop = LBound(aSites) to UBound(aSites)
  Response.Write aSites(iLoop) & "<BR>"
Next
response.write "<br><b>Resultado al reordenar: <P></b>"

'Jumble up the array and display the new, random order!
aSites = ReOrderArrayQuickNDirty(aSites)
For iLoop = LBound(aSites) to UBound(aSites)
  Response.Write aSites(iLoop) & "<BR>"
Next
%>